import java.util.Objects;
import java.util.Set;
import java.util.TreeSet;

class Student {
    public String id;
    public Student(String id) {
        this.id = id;
    }

    /**
     * 使可比较
     * @param o
     * @return
     */
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return Objects.equals(id, student.id);
    }

    /**
     * 拿到哈希值
     * @return
     */
    @Override
    public int hashCode() {
        return Objects.hash(id);
    }

    /**
     * 打印Student
     * @return
     */
    @Override
    public String toString() {
        return "Student{" +
                "id='" + id + '\'' +
                '}';
    }
}
public class Test {
    /**
     * 宝石和石头
     * @param jewels
     * @param stones
     * @return
     */
    public int numJewelsInStones(String jewels, String stones) {
        Set<Character> set = new TreeSet<>();
        for(int i = 0;i < jewels.length();i++) {
            char ch = jewels.charAt(i);
            set.add(ch);
        }

        int count = 0;
        for(int i = 0;i < stones.length();i++) {
            char ch = stones.charAt(i);
            if(set.contains(ch)) {
                count++;
            }
        }
        return count;
    }
    /**
     * 只出现一次的数字
     * @param nums
     * @return
     */
    public int singleNumber(int[] nums) {
        TreeSet<Integer> set = new TreeSet<>();
        for(int i = 0;i < nums.length;i++) {
            if(set.contains(nums[i])) {
                set.remove(nums[i]);
            }else {
                set.add(nums[i]);
            }
        }

        for(int i = 0;i < nums.length;i++) {
            if(set.contains(nums[i])) {
                return nums[i];
            }
        }

        return -1;
    }
    public static void main(String[] args) {
        Student student = new Student("123456");
        Student student2 = new Student("123456");
        HashBuck2<Student,Integer> hashBuck2 = new HashBuck2<>();
        hashBuck2.push(student,888);
        System.out.println(hashBuck2.get(student2));
    }
    public static void main1(String[] args) {
        HashBuck hashBuck = new HashBuck();
        hashBuck.push(1,888);
        hashBuck.push(2,888);
        hashBuck.push(3,888);
        hashBuck.push(4,888);
        hashBuck.push(5,888);
        hashBuck.push(6,888);
        hashBuck.push(14,999);
        hashBuck.push(7,888);
        System.out.println();
        System.out.println(hashBuck.get(14));
        System.out.println(hashBuck.get(100));
    }
}
